package com.zy.cat.entity.jd;

import java.io.Serializable;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zy.cat.common.utils.TJKUtils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;

@Data
@RequiredArgsConstructor
@AllArgsConstructor
@ApiModel("京东商品实体类")
public class JDGoods implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 134463333332222L;

	@ApiModelProperty("预估佣金")
	private long fcode;

	@ApiModelProperty("商品落地页，用于高佣转链")
	private String materialUrl;

	@ApiModelProperty("商品名称")
	private String skuName;

	@ApiModelProperty("站长角色：1 推客 2 团长")
	private String unionRole;

	@ApiModelProperty("礼金分摊金额")
	private String giftCouponOcsAmount;

	@JsonIgnore
	@ApiModelProperty("拼购信息")
	private PinGouInfo pinGouInfo;

	@ApiModelProperty("类目信息")
	private CategoryInfo categoryInfo;

	@ApiModelProperty("spuid，其值为同款商品的主skuid")
	private String spuid;

	@ApiModelProperty("视频信息")
	private VideoInfo videoInfo;

	@ApiModelProperty("是否爆款，1：是，0：否")
	private String isHot;

	@ApiModelProperty("品牌名称")
	private String brandName;

	@ApiModelProperty("图片信息")
	private ImageInfo imageInfo;

	@ApiModelProperty("品牌code")
	private String brandCode;

	@ApiModelProperty("价格信息")
	private PriceInfo priceInfo;

	@ApiModelProperty("店铺信息")
	private ShopInfo shopInfo;

	@ApiModelProperty("京喜商品类型，1京喜、2京喜工厂直供、3京喜优选（包含3时可在京东APP购买）")
	private Integer[] jxFlags;

	@ApiModelProperty("g=自营，p=pop")
	private String owner;

	@ApiModelProperty("相似推荐商品skuId集合")
	private List<Long> similarSkuList;

	@JsonIgnore
	@ApiModelProperty("佣金信息")
	private CommissionInfo commissionInfo;

	@ApiModelProperty("商品ID")
	private String skuId;

	@ApiModelProperty("商品好评率")
	private String goodCommentsShare;

	@ApiModelProperty("优惠券信息，返回内容为空说明该SKU无可用优惠券")
	private CouponInfo couponInfo;

	@ApiModelProperty("30天引单数量")
	private Long inOrderCount30Days;

	@ApiModelProperty("评论数")
	private String comments;

	@ApiModelProperty("评价信息")
	private CommentInfo commentInfo;

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品拼购信息实体类")
	public static class PinGouInfo {
		@ApiModelProperty("拼购成团所需人数")
		private String pingouTmCount;

		@ApiModelProperty("拼购落地页url")
		private String pingouUrl;

		@ApiModelProperty("拼购结束时间")
		private String pingouEndTime;

		@ApiModelProperty("拼购价格")
		private String pingouPrice;

		@ApiModelProperty("拼购开始时间")
		private String pingouStartTime;

		public void setPingouStartTime(String pingouStartTime) {
			if (StringUtils.isNumeric(pingouStartTime)) {
				this.pingouStartTime = TJKUtils.UnixToDateTime(null, Long.parseLong(pingouStartTime));
			} else {
				this.pingouStartTime = "";
			}
		}

		public void setPingouEndTime(String pingouEndTime) {
			if (StringUtils.isNumeric(pingouEndTime)) {
				this.pingouEndTime = TJKUtils.UnixToDateTime(null, Long.parseLong(pingouEndTime));
			} else {
				this.pingouEndTime = "";
			}
		}

	}

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品类目信息实体类")
	public static class CategoryInfo {
		@ApiModelProperty("三级类目id")
		private String cid3;

		@ApiModelProperty("二级类目名称")
		private String cid2Name;

		@ApiModelProperty("二级类目id")
		private String cid2;

		@ApiModelProperty("三级类目名称")
		private String cid3Name;

		@ApiModelProperty("一级类目名称")
		private String cid1Name;

		@ApiModelProperty("一级类目id")
		private String cid1;
	}

//	@Data
//	@RequiredArgsConstructor
//	@AllArgsConstructor
//	@ApiModel("京东商品AAA实体类")
//	public static class VideoList {
//		private Video video;
//	}

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品视频实体类")
	public static class VideoInfo {
		@ApiModelProperty("视频列表")
		private List<Video> videoList;

		@Data
		@RequiredArgsConstructor
		@AllArgsConstructor
		@ApiModel("视频明细体类")
		public static class Video {
			@ApiModelProperty("播放地址")
			private String playUrl;

			@ApiModelProperty("时长(单位:s)")
			private String duration;

			@ApiModelProperty("视频图片地址")
			private String imageUrl;

			@ApiModelProperty("宽")
			private String width;

			@ApiModelProperty("low：标清，high：高清")
			private String playType;

			@ApiModelProperty("高")
			private String high;

			@ApiModelProperty("1:主图，2：商详")
			private String videoType;
		}
	}

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品AAA实体类")
	public static class UrlInfo {
		@ApiModelProperty("图片地址")
		private String url;
	}

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品图片信息实体类")
	public static class ImageInfo {
		@ApiModelProperty("图片列表")
		private List<UrlInfo> imageList;
	}

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品价格信息实体类")
	public static class PriceInfo {

		@ApiModelProperty("无线价格")
		private String price;

		@ApiModelProperty("最低价后的优惠券价最低价后的优惠券价(当商品无最优券时，不返回该字段)")
		private String lowestCouponPrice;

		@ApiModelProperty("最低价格类型，1：无线价格；2：拼购价格； 3：秒杀价格")
		private String lowestPriceType;

		@ApiModelProperty("最低价格")
		private String lowestPrice;

	}

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品店铺信息实体类")
	public static class ShopInfo {

		@ApiModelProperty("店铺ID")
		private String shopId;

		@ApiModelProperty("店铺名称")
		private String shopName;

		@ApiModelProperty("店铺等级")
		private String shopLevel;

	}

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品佣金信息实体类")
	public static class CommissionInfo {

		@ApiModelProperty("佣金比例")
		private Double commissionShare;

		@ApiModelProperty("券后佣金")
		private Double couponCommission;

		@ApiModelProperty("plus券后佣金比例")
		private Double plusCommissionShare;

		@ApiModelProperty("佣金")
		private Double commission;

	}

//	@Data
//	@RequiredArgsConstructor
//	@AllArgsConstructor
//	@ApiModel("优惠券集合实体类")
//	public static class CouponList {
//		@ApiModelProperty("优惠券集合")
//		private Coupon coupon;
//	}

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品优惠券信息实体类")
	public static class CouponInfo {
		@ApiModelProperty("优惠券集合")
		private List<Coupon> couponList;

		@Data
		@RequiredArgsConstructor
		@AllArgsConstructor
		@ApiModel("京东商品优惠券明细实体类")
		public static class Coupon {
			@ApiModelProperty("券领取结束时间")
			private String getEndTime;

			@ApiModelProperty("领取开始时间")
			private String getStartTime;

			@ApiModelProperty("券消费限额")
			private String quota;

			@ApiModelProperty("券使用平台 (平台类型：0 - 全平台券，1 - 限平台券)")
			private String platformType;

			@ApiModelProperty("券有效使用结束时间")
			private String useEndTime;

			@ApiModelProperty("券有效使用开始时间")
			private String useStartTime;

			@ApiModelProperty("券种类 (优惠券种类：0 - 全品类，1 - 限品类（自营商品），2 - 限店铺，3 - 店铺限商品券)")
			private String bindType;

			@ApiModelProperty("最优优惠券，1：是；0：否")
			private String isBest;

			@ApiModelProperty("券链接")
			private String link;

			@ApiModelProperty("券面额")
			private String discount;

			public void setGetEndTime(String getEndTime) {
				if (StringUtils.isNumeric(getEndTime)) {
					this.getEndTime = TJKUtils.UnixToDateTime(null, Long.parseLong(getEndTime));
				} else {
					this.getEndTime = "";
				}
			}

			public void setGetStartTime(String getStartTime) {
				if (StringUtils.isNumeric(getStartTime)) {
					this.getStartTime = TJKUtils.UnixToDateTime(null, Long.parseLong(getStartTime));
				} else {
					this.getStartTime = "";
				}
			}

			public void setUseEndTime(String useEndTime) {
				if (StringUtils.isNumeric(useEndTime)) {
					this.useEndTime = TJKUtils.UnixToDateTime(null, Long.parseLong(useEndTime));
				} else {
					this.useEndTime = "";
				}
			}

			public void setUseStartTime(String useStartTime) {
				if (StringUtils.isNumeric(useStartTime)) {
					this.useStartTime = TJKUtils.UnixToDateTime(null, Long.parseLong(useStartTime));
				} else {
					this.useStartTime = "";
				}
			}
		}
	}

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品评价详情实体类")
	public static class CommentList {
		@ApiModelProperty("评价内容")
		private String content;

		@ApiModelProperty("评价图片集合")
		private List<UrlInfo> imageList;
	}

	@Data
	@RequiredArgsConstructor
	@AllArgsConstructor
	@ApiModel("京东商品评价信息实体类")
	public static class CommentInfo {
		@ApiModelProperty("评价集合")
		private List<CommentList> commentList;

	}

}
